package com.lm.survey.model;

import java.util.ArrayList;
import java.util.List;

public class QuestionPackage {
    String code;
    String name;
    String comment;
    boolean onlySelfTest = true;
    List<QuestionRelation> rels = new ArrayList<QuestionRelation>();
    public boolean isOnlySelfTest() {
        return onlySelfTest;
    }
    public void setOnlySelfTest(boolean onlySelfTest) {
        this.onlySelfTest = onlySelfTest;
    }

    
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getComment() {
        return comment;
    }
    public void setComment(String comment) {
        this.comment = comment;
    }
    public List<QuestionRelation> getRels() {
        return rels;
    }
    public void setRels(List<QuestionRelation> rels) {
        this.rels = rels;
    } 
    
    public void addRel(QuestionRelation rel){
        if(onlySelfTest&&rel.haveRelation(4)){
            if(rel.getRelation().length()<=2){
                this.onlySelfTest = true;
                
            }else{
                this.onlySelfTest = false;
            }
           
        }else {
            this.onlySelfTest = false;
        }
        this.rels.add(rel);
    }
    
}
